<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf8">
		<title>甜橙云音乐</title>
        <link href="{{ url_for('static',filename='css/pt_discover_index.css')}}" type="text/css" rel="stylesheet">
        <link href="{{ url_for('static',filename='css/pt_frame.css')}}" type="text/css" rel="stylesheet">
        <script type="text/javascript" src="{{url_for('static',filename='js/jquery-2.2.0.min.js')}}"></script>
        <script type="text/javascript" src="{{url_for('static',filename='js/layer/layer.js')}}"></script>
	</head>
	<body style="background: url('../../static/image/bg.jpg') repeat-y 100% 100%;">
		<div data-module="" data-sub="" id="g_top" class="m-top">
			&nbsp;
		</div>
		<div id="g_nav" class="m-subnav m-subnav-up f-pr">
			<div class="shadow">
				&nbsp;
			</div>
		</div>
        <div class="g-bd" style="padding-top:30px">
            <div class="g-wrap" id="baseBox">
                <ul class="m-tabs f-cb" style="background: #f2d497;">
                    <li class="fst">
                        <a ><em>新增歌曲</em>
                        </a>
                    </li>
                </ul>
                <form onsubmit="return false" >
                    <div class="n-base f-cb">
                        <div class="frm m-frm">
                            <div class="itm">
                                歌曲名称：<input type="text" class="u-txt txt" id="songName"  name="songName" maxlength="30">
                            </div>
                            <div class="itm">
                                歌手：
                                <input type="text" class="u-txt txt" id="singer"  name="singer" maxlength="30">
                            </div>
                            <div class="itm">
                                分类：
                                <select name="style" id="style" class="u-txt txt" style="height:auto">
                                    <option value="1">
                                        华语
                                    </option>
                                    <option value="2">
                                        欧美
                                    </option>
                                    <option value="3">
                                        日语
                                    </option>
                                    <option value="4">
                                        韩语
                                    </option>
                                    <option value="5">
                                        其他
                                    </option>
                                </select>
                            </div>
                            <div class="itm">
                                歌曲文件地址：<input type="text" class="u-txt txt" id="fileURL" name="fileURL" maxlength="30">
                            </div>
                            <div class="itm ft">
								<button name="submit" type="button" id="save">保存</button>
								<button onclick="history.go(-1)"  type="button">返回</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
<script>
    $('#save').click(function(){
        var songName = $('#songName').val();
        var singer = $('#singer').val();
        var fileURL = $('#fileURL').val();
        var style =  $('#style').val();
        if(songName == ""){
            layer.msg("歌曲名不能为空！",{icon:2,time:1000});
            return false;
		}
		if(singer == ""){
            layer.msg("歌手名不能为空！",{icon:2,time:1000});
            return false;
		}
		if(fileURL == ""){
			layer.msg("歌曲文件不能为空！",{icon:2,time:1000});
			return false;
		}
        $.ajax({                                    // 使用Ajax异步提交
            url: "{{ url_for('home.manageSongAdd') }}",   // 提交到的URL
            type: "POST",                            // 提交方式为POST
            data:{songName: songName,singer:singer,style:style,fileURL:fileURL},// 传递参数
            dataType: "json",                       // 数据类型为json
            success: function (res) {               // 操作成功后执行逻辑
                if (res.status == 1) {
                    layer.msg(res.message,{icon:1,time:2000},function(){
                        window.location.href='/manage_song_add';
                    });
                } else {
                    layer.msg(res.message,{icon:2,time:2000});
                }
            }
        })
    })
</script>
	</body>
</html>
